<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="fixOrdersList"  fitColumns="true" title="活动借用申请" actionUrl="deviceFixController.do?datagrid" idField="id" fit="true" >
	
	 <t:dgCol title="状态值"  field="stateValue"  hidden="true"  queryMode="single"  width="120"></t:dgCol> 
	  <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
	  <t:dgCol title="创建日期"  field="createDate" formatter="yyyy-MM-dd"   width="120"></t:dgCol>  
	  <t:dgCol title="设备名称"  field="deviceName"  queryMode="single"  width="120"></t:dgCol>
	  <t:dgCol title="设备品牌"  field="device.brand.brandName"   queryMode="single"  width="120"></t:dgCol>
	  <t:dgCol title="设备型号"  field="deviceType.modelName"   queryMode="single"  width="120"></t:dgCol>
	  <t:dgCol title="设备编号"  field="device.deviceNo"  query="true"  queryMode="single"  width="120"></t:dgCol> 
	  <t:dgCol title="存放地"  field="storage"    queryMode="single"  width="120"></t:dgCol>
	  <t:dgCol title="维修状态"  field="fixState.name"    queryMode="single"  width="120"></t:dgCol>
	  <t:dgCol title="操作" field="opt" width="130"></t:dgCol>
  	  <t:dgFunOpt funname="passApply(id)" title="维修完成" exp="stateValue#eq#0"></t:dgFunOpt> 
	  <t:dgToolBar title="添加维修记录" icon="icon-add" funname="addRecord" ></t:dgToolBar>
	  <t:dgToolBar title="查看维修记录" icon="icon-search" funname="goDetail" ></t:dgToolBar>
	  
  </t:datagrid>
  </div>
 </div>
 <script type="text/javascript"> 
	function addRecord(){
		var rowsData = $('#fixOrdersList').datagrid('getSelections');
		if (!rowsData || rowsData.length == 0) {
			tip('请选择编辑项目');
			return;
		}else{
			var state = rowsData[0].stateValue;
			if(state != 0 ){
				tip('设备已经维修完成，不能添加维修记录！');
				return;
			}
			createwindow('维修记录','deviceFixController.do?fixRecordWindow&oid='+rowsData[0].id, 400, 200);
		}
	}
	
	function goDetail(){
		var rowsData = $('#fixOrdersList').datagrid('getSelections');
		if (!rowsData || rowsData.length == 0) {
			tip('请选择编辑项目');
			return;
		}else{
			createdetailwindow("维修记录",'deviceFixController.do?goDetail&id='+rowsData[0].id,400,400);
		}
	}
	
	function passApply(id){
		$.dialog.confirm('确定要修改为维修完成吗?', function(r) {
			   if (r) { 
					$.ajax({
						url : 'deviceFixController.do?fixover&id='+id,
						type : 'post', 
						cache : false,
						success : function(data) {
							var d = $.parseJSON(data);
							if (d.success) {
								var msg = d.msg;
								tip(msg);
								reloadTable(); 
							}else{
								tip(msg);
							}
						}
					});
				}
			}); 
	}
	
 </script>